<%@ page contentType="text/html;charset=UTF-8" pageEncoding="utf-8" trimDirectiveWhitespaces="true" %>
<%@ taglib tagdir="/WEB-INF/tags" prefix="my" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="s" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<fmt:message var="title" key="contact.list.title"/>
<my:layout title="${title}">
 <jsp:attribute name="body">
<img src="../telefon_kontakt.png" width="200" height="200" alt="kontakt" align="right">
        <p><fmt:message key="contact.list.allContacts"/></p>

        <table class="basic">
            <tr>
                <th>id</th>
                <th><fmt:message key="user.name"/></th>
                <th><fmt:message key="user.surname"/></th>
                <th><fmt:message key="user.email"/></th>
                <th><fmt:message key="user.city"/></th>
                <th><fmt:message key="user.street"/></th>
                <th><fmt:message key="user.zip"/></th>
                <th><fmt:message key="user.phone"/></th>
                <th></th>
                <th></th>
            </tr>
            <c:forEach items="${contacts}" var="contact">
                <tr>
                    <td>${contact.id}</td>
                    <td><c:out value="${contact.name}"/></td>
                    <td><c:out value="${contact.surname}"/></td>
                    <td><c:out value="${contact.email}"/></td>
                    <td><c:out value="${contact.city}"/></td>
                    <td><c:out value="${contact.street}"/></td>
                    <td><c:out value="${contact.zip}"/></td>
                    <td><c:out value="${contact.phone}"/></td>
                    <td>
                        <form method="get" action="${pageContext.request.contextPath}/contact/update/${contact.id}">
                            <input type="submit" value="<fmt:message key='contact.list.edit'/>">
                        </form>
                    </td>
                    <td>
                        <form method="post" action="${pageContext.request.contextPath}/contact/delete/${contact.id}">
                            <input type="submit" value="<fmt:message key='contact.list.delete'/>">
                        </form>
                    </td>

                </tr>
            </c:forEach>
        </table>

<form:form method="post" action="${pageContext.request.contextPath}/contact/update" commandName="contact" modelAttribute="contact">
    <fieldset><legend><fmt:message key="contact.list.newContact"/></legend>
    <%@include file="form.jsp"%>
    <input type="submit" value="<fmt:message key='contact.list.createContact'/>">
    </fieldset>
</form:form>
</jsp:attribute>
</my:layout>